// yarn add http-proxy-middleware --dev / npm i -D http-proxy-middleware
// 引入代理模块
const { createProxyMiddleware: proxy } = require('http-proxy-middleware');

// 导出模块
module.exports = app => {

  // 匹配代理路由规则
  app.use('/api', proxy({
    target: 'http://localhost:9000',
    changeOrigin: true,
    pathRewrite: {
      '^/api': ''
    }
  }))

}

